 package handling.channel.handler;


import client.*;
import client.inventory.*;
import client.skills.Skill;
import client.skills.SkillFactory;
import configs.ServerConfig;
import constants.ItemConstants;
import handling.world.WorldBroadcastService;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import server.ItemMakerFactory;
import server.MapleInventoryManipulator;
import server.MapleItemInformationProvider;
import server.MapleStatEffect;
import server.maps.MapleExtractor;
import server.maps.MapleReactor;
import server.quest.MapleQuest;
import tools.*;
import tools.data.input.LittleEndianAccessor;
import tools.packet.EffectPacket;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;































 public class ItemMakerHandler {
/*   34 */   private static final Logger log = LogManager.getLogger(ItemMakerHandler.class);
/*   35 */   private static final Map<String, Integer> craftingEffects = new HashMap<>();

   static {
/*   38 */     craftingEffects.put("Effect/BasicEff.img/professions/herbalism", Integer.valueOf(92000000));
/*   39 */     craftingEffects.put("Effect/BasicEff.img/professions/mining", Integer.valueOf(92010000));
/*   40 */     craftingEffects.put("Effect/BasicEff.img/professions/herbalismExtract", Integer.valueOf(92000000));
/*   41 */     craftingEffects.put("Effect/BasicEff.img/professions/miningExtract", Integer.valueOf(92010000));

/*   43 */     craftingEffects.put("Effect/BasicEff.img/professions/equip_product", Integer.valueOf(92020000));
/*   44 */     craftingEffects.put("Effect/BasicEff.img/professions/acc_product", Integer.valueOf(92030000));
/*   45 */     craftingEffects.put("Effect/BasicEff.img/professions/alchemy", Integer.valueOf(92040000)); } public static void ItemMaker(LittleEndianAccessor slea, MapleClient c) { int toCreate, etc, itemId; boolean stimulator;
     short slot;
     int numEnchanter;
     Item toUse;
     ItemMakerFactory.ItemMakerCreateEntry create;
     MapleItemInformationProvider ii, mapleItemInformationProvider1;
     Equip toGive;
/*   52 */     int makerType = slea.readInt();
/*   53 */     switch (makerType) {
       case 1:
/*   55 */         toCreate = slea.readInt();
/*   56 */         if (ItemConstants.is强化宝石(toCreate)) {
/*   57 */           ItemMakerFactory.GemCreateEntry gem = ItemMakerFactory.getInstance().getGemInfo(toCreate);
/*   58 */           if (gem == null) {
             return;
           }
/*   61 */           if (!hasSkill(c, gem.getReqSkillLevel())) {
             return;
           }
/*   64 */           if (c.getPlayer().getMeso() < gem.getCost()) {
             return;
           }
/*   67 */           int randGemGiven = getRandomGem(gem.getRandomReward());
/*   68 */           if (c.getPlayer().getInventory(ItemConstants.getInventoryType(randGemGiven)).isFull()) {
             return;
           }
/*   71 */           int taken = checkRequiredNRemove(c, gem.getReqRecipes());
/*   72 */           if (taken == 0) {
             return;
           }
/*   75 */           c.getPlayer().gainMeso(-gem.getCost(), false);
/*   76 */           MapleInventoryManipulator.addById(c, randGemGiven, (short)(byte)((taken == randGemGiven) ? 9 : 1), "Made by Gem " + toCreate + " on " + DateUtil.getCurrentDate());
/*   77 */           c.announce(EffectPacket.ItemMaker_Success());
/*   78 */           c.getPlayer().getMap().broadcastMessage(c.getPlayer(), EffectPacket.ItemMaker_Success_3rdParty(c.getPlayer().getId()), false); break;
/*   79 */         }  if (ItemConstants.isOtherGem(toCreate)) {


/*   82 */           ItemMakerFactory.GemCreateEntry gem = ItemMakerFactory.getInstance().getGemInfo(toCreate);
/*   83 */           if (gem == null) {
             return;
           }
/*   86 */           if (!hasSkill(c, gem.getReqSkillLevel())) {
             return;
           }
/*   89 */           if (c.getPlayer().getMeso() < gem.getCost()) {
             return;
           }
/*   92 */           if (c.getPlayer().getInventory(ItemConstants.getInventoryType(toCreate)).isFull()) {
             return;
           }
/*   95 */           if (checkRequiredNRemove(c, gem.getReqRecipes()) == 0) {
             return;
           }
/*   98 */           c.getPlayer().gainMeso(-gem.getCost(), false);
/*   99 */           if (ItemConstants.getInventoryType(toCreate) == MapleInventoryType.EQUIP) {
/*  100 */             MapleInventoryManipulator.addbyItem(c, MapleItemInformationProvider.getInstance().getEquipById(toCreate));
           } else {
/*  102 */             MapleInventoryManipulator.addById(c, toCreate, (short)1, "Made by Gem " + toCreate + " on " + DateUtil.getCurrentDate());
           }
/*  104 */           c.announce(EffectPacket.ItemMaker_Success());
/*  105 */           c.getPlayer().getMap().broadcastMessage(c.getPlayer(), EffectPacket.ItemMaker_Success_3rdParty(c.getPlayer().getId()), false); break;
         }
/*  107 */         stimulator = (slea.readByte() > 0);
/*  108 */         numEnchanter = slea.readInt();
/*  109 */         create = ItemMakerFactory.getInstance().getCreateInfo(toCreate);
/*  110 */         if (create == null) {
           return;
         }
/*  113 */         if (numEnchanter > create.getTUC()) {
           return;
         }
/*  116 */         if (!hasSkill(c, create.getReqSkillLevel())) {
           return;
         }
/*  119 */         if (c.getPlayer().getMeso() < create.getCost()) {
           return;
         }
/*  122 */         if (c.getPlayer().getInventory(ItemConstants.getInventoryType(toCreate)).isFull()) {
           return;
         }
/*  125 */         if (checkRequiredNRemove(c, create.getReqItems()) == 0) {
           return;
         }
/*  128 */         c.getPlayer().gainMeso(-create.getCost(), false);
/*  129 */         mapleItemInformationProvider1 = MapleItemInformationProvider.getInstance();
/*  130 */         toGive = (Equip)mapleItemInformationProvider1.getEquipById(toCreate);
/*  131 */         if (stimulator || numEnchanter > 0) {
/*  132 */           if (c.getPlayer().haveItem(create.getStimulator(), 1, false, true)) {
/*  133 */             mapleItemInformationProvider1.randomizeStats_Above(toGive);
/*  134 */             MapleInventoryManipulator.removeById(c, MapleInventoryType.ETC, create.getStimulator(), 1, false, false);
           }
/*  136 */           for (int i = 0; i < numEnchanter; i++) {
/*  137 */             int enchant = slea.readInt();
/*  138 */             if (c.getPlayer().haveItem(enchant, 1, false, true)) {
/*  139 */               Map<String, Integer> stats = mapleItemInformationProvider1.getItemBaseInfo(enchant);
/*  140 */               if (stats != null) {
/*  141 */                 addEnchantStats(stats, toGive);
/*  142 */                 MapleInventoryManipulator.removeById(c, MapleInventoryType.ETC, enchant, 1, false, false);
               }
             }
           }
         }
/*  147 */         if (!stimulator || Randomizer.nextInt(10) != 0) {
/*  148 */           MapleInventoryManipulator.addbyItem(c, (Item)toGive);
/*  149 */           c.getPlayer().getMap().broadcastMessage(c.getPlayer(), EffectPacket.ItemMaker_Success_3rdParty(c.getPlayer().getId()), false);
         } else {
/*  151 */           c.getPlayer().dropMessage(5, "The item was overwhelmed by the stimulator.");
         }
/*  153 */         c.announce(EffectPacket.ItemMaker_Success());
         break;


       case 3:
/*  158 */         etc = slea.readInt();
/*  159 */         if (c.getPlayer().haveItem(etc, 100, false, true)) {
/*  160 */           MapleInventoryManipulator.addById(c, getCreateCrystal(etc), (short)1, "Made by Maker " + etc + " on " + DateUtil.getCurrentDate());
/*  161 */           MapleInventoryManipulator.removeById(c, MapleInventoryType.ETC, etc, 100, false, false);
/*  162 */           c.announce(EffectPacket.ItemMaker_Success());
/*  163 */           c.getPlayer().getMap().broadcastMessage(c.getPlayer(), EffectPacket.ItemMaker_Success_3rdParty(c.getPlayer().getId()), false);
         }
         break;

       case 4:
/*  168 */         itemId = slea.readInt();
/*  169 */         c.getPlayer().updateTick(slea.readInt());
/*  170 */         slot = (short)slea.readInt();
/*  171 */         toUse = c.getPlayer().getInventory(MapleInventoryType.EQUIP).getItem(slot);
/*  172 */         if (toUse == null || toUse.getItemId() != itemId || toUse.getQuantity() < 1) {
           return;
         }
/*  175 */         ii = MapleItemInformationProvider.getInstance();
/*  176 */         if (!ii.isDropRestricted(itemId) && !ii.isAccountShared(itemId)) {
/*  177 */           int[] arrayOfInt = getCrystal(itemId, ii.getReqLevel(itemId));
/*  178 */           MapleInventoryManipulator.addById(c, arrayOfInt[0], (short)(byte)arrayOfInt[1], "Made by disassemble " + itemId + " on " + DateUtil.getCurrentDate());
/*  179 */           MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.EQUIP, slot, (short)1, false);
         }
/*  181 */         c.announce(EffectPacket.ItemMaker_Success());
/*  182 */         c.getPlayer().getMap().broadcastMessage(c.getPlayer(), EffectPacket.ItemMaker_Success_3rdParty(c.getPlayer().getId()), false);
         break;
     }  }



   private static int getCreateCrystal(int etc) {
     int itemid;
/*  190 */     short level = MapleItemInformationProvider.getInstance().getItemMakeLevel(etc);
/*  191 */     if (level >= 31 && level <= 50) {
/*  192 */       itemid = 4260000;
/*  193 */     } else if (level >= 51 && level <= 60) {
/*  194 */       itemid = 4260001;
/*  195 */     } else if (level >= 61 && level <= 70) {
/*  196 */       itemid = 4260002;
/*  197 */     } else if (level >= 71 && level <= 80) {
/*  198 */       itemid = 4260003;
/*  199 */     } else if (level >= 81 && level <= 90) {
/*  200 */       itemid = 4260004;
/*  201 */     } else if (level >= 91 && level <= 100) {
/*  202 */       itemid = 4260005;
/*  203 */     } else if (level >= 101 && level <= 110) {
/*  204 */       itemid = 4260006;
/*  205 */     } else if (level >= 111 && level <= 120) {
/*  206 */       itemid = 4260007;
/*  207 */     } else if (level >= 121) {
/*  208 */       itemid = 4260008;
     } else {
/*  210 */       throw new RuntimeException("Invalid Item Maker id");
     }
/*  212 */     return itemid;
   }

   private static int[] getCrystal(int itemid, int level) {
/*  216 */     int[] all = new int[2];
/*  217 */     all[0] = -1;
/*  218 */     if (level >= 31 && level <= 50) {
/*  219 */       all[0] = 4260000;
/*  220 */     } else if (level >= 51 && level <= 60) {
/*  221 */       all[0] = 4260001;
/*  222 */     } else if (level >= 61 && level <= 70) {
/*  223 */       all[0] = 4260002;
/*  224 */     } else if (level >= 71 && level <= 80) {
/*  225 */       all[0] = 4260003;
/*  226 */     } else if (level >= 81 && level <= 90) {
/*  227 */       all[0] = 4260004;
/*  228 */     } else if (level >= 91 && level <= 100) {
/*  229 */       all[0] = 4260005;
/*  230 */     } else if (level >= 101 && level <= 110) {
/*  231 */       all[0] = 4260006;
/*  232 */     } else if (level >= 111 && level <= 120) {
/*  233 */       all[0] = 4260007;
/*  234 */     } else if (level >= 121 && level <= 200) {
/*  235 */       all[0] = 4260008;
     } else {
/*  237 */       throw new RuntimeException("Invalid Item Maker type" + level);
     }
/*  239 */     if (ItemConstants.isWeapon(itemid) || ItemConstants.isOverall(itemid)) {
/*  240 */       all[1] = Randomizer.rand(5, 11);
     } else {
/*  242 */       all[1] = Randomizer.rand(3, 7);
     }
/*  244 */     return all;
   }

   private static void addEnchantStats(Map<String, Integer> stats, Equip item) {
/*  248 */     Integer s = stats.get("incPAD");
/*  249 */     if (s != null && s.intValue() != 0) {
/*  250 */       item.setWatk((short)(item.getWatk() + s.intValue()));
     }
/*  252 */     s = stats.get("incMAD");
/*  253 */     if (s != null && s.intValue() != 0) {
/*  254 */       item.setMatk((short)(item.getMatk() + s.intValue()));
     }
/*  256 */     s = stats.get("incACC");
/*  257 */     if (s != null && s.intValue() != 0) {
/*  258 */       item.setAcc((short)(item.getAcc() + s.intValue()));
     }
/*  260 */     s = stats.get("incEVA");
/*  261 */     if (s != null && s.intValue() != 0) {
/*  262 */       item.setAvoid((short)(item.getAvoid() + s.intValue()));
     }
/*  264 */     s = stats.get("incSpeed");
/*  265 */     if (s != null && s.intValue() != 0) {
/*  266 */       item.setSpeed((short)(item.getSpeed() + s.intValue()));
     }
/*  268 */     s = stats.get("incJump");
/*  269 */     if (s != null && s.intValue() != 0) {
/*  270 */       item.setJump((short)(item.getJump() + s.intValue()));
     }
/*  272 */     s = stats.get("MaxHP");
/*  273 */     if (s != null && s.intValue() != 0) {
/*  274 */       item.setHp((short)(item.getHp() + s.intValue()));
     }
/*  276 */     s = stats.get("MaxMP");
/*  277 */     if (s != null && s.intValue() != 0) {
/*  278 */       item.setMp((short)(item.getMp() + s.intValue()));
     }
/*  280 */     s = stats.get("incSTR");
/*  281 */     if (s != null && s.intValue() != 0) {
/*  282 */       item.setStr((short)(item.getStr() + s.intValue()));
     }
/*  284 */     s = stats.get("incDEX");
/*  285 */     if (s != null && s.intValue() != 0) {
/*  286 */       item.setDex((short)(item.getDex() + s.intValue()));
     }
/*  288 */     s = stats.get("incINT");
/*  289 */     if (s != null && s.intValue() != 0) {
/*  290 */       item.setInt((short)(item.getInt() + s.intValue()));
     }
/*  292 */     s = stats.get("incLUK");
/*  293 */     if (s != null && s.intValue() != 0) {
/*  294 */       item.setLuk((short)(item.getLuk() + s.intValue()));
     }
/*  296 */     s = stats.get("randOption");
/*  297 */     if (s != null && s.intValue() != 0) {
/*  298 */       int ma = item.getMatk(), wa = item.getWatk();
/*  299 */       if (wa > 0) {
/*  300 */         item.setWatk((short)(Randomizer.nextBoolean() ? (wa + s.intValue()) : (wa - s.intValue())));
       }
/*  302 */       if (ma > 0) {
/*  303 */         item.setMatk((short)(Randomizer.nextBoolean() ? (ma + s.intValue()) : (ma - s.intValue())));
       }
     }
/*  306 */     s = stats.get("randStat");
/*  307 */     if (s != null && s.intValue() != 0) {
/*  308 */       int str = item.getStr(), dex = item.getDex(), luk = item.getLuk(), int_ = item.getInt();
/*  309 */       if (str > 0) {
/*  310 */         item.setStr((short)(Randomizer.nextBoolean() ? (str + s.intValue()) : (str - s.intValue())));
       }
/*  312 */       if (dex > 0) {
/*  313 */         item.setDex((short)(Randomizer.nextBoolean() ? (dex + s.intValue()) : (dex - s.intValue())));
       }
/*  315 */       if (int_ > 0) {
/*  316 */         item.setInt((short)(Randomizer.nextBoolean() ? (int_ + s.intValue()) : (int_ - s.intValue())));
       }
/*  318 */       if (luk > 0) {
/*  319 */         item.setLuk((short)(Randomizer.nextBoolean() ? (luk + s.intValue()) : (luk - s.intValue())));
       }
     }
   }


   private static int getRandomGem(List<Pair<Integer, Integer>> rewards) {
/*  326 */     List<Integer> items = new ArrayList<>();
/*  327 */     for (Pair<Integer, Integer> p : rewards) {
/*  328 */       int itemid = ((Integer)p.getLeft()).intValue();
/*  329 */       for (int i = 0; i < ((Integer)p.getRight()).intValue(); i++) {
/*  330 */         items.add(Integer.valueOf(itemid));
       }
     }
/*  333 */     return ((Integer)items.get(Randomizer.nextInt(items.size()))).intValue();
   }

   private static int checkRequiredNRemove(MapleClient c, List<Pair<Integer, Integer>> recipe) {
/*  337 */     int itemid = 0;
/*  338 */     for (Pair<Integer, Integer> p : recipe) {
/*  339 */       if (!c.getPlayer().haveItem(((Integer)p.getLeft()).intValue(), ((Integer)p.getRight()).intValue(), false, true)) {
/*  340 */         return 0;
       }
     }
/*  343 */     for (Pair<Integer, Integer> p : recipe) {
/*  344 */       itemid = ((Integer)p.getLeft()).intValue();
/*  345 */       MapleInventoryManipulator.removeById(c, ItemConstants.getInventoryType(itemid), itemid, ((Integer)p.getRight()).intValue(), false, false);
     }
/*  347 */     return itemid;
   }

   private static boolean hasSkill(MapleClient c, int reqlvl) {
/*  351 */     return (c.getPlayer().getSkillLevel(SkillFactory.getSkill(PlayerStats.getSkillByJob(1007, c.getPlayer().getJob()))) >= reqlvl);
   }




   public static void UseRecipe(LittleEndianAccessor slea, MapleClient c, MapleCharacter chr) {
/*  358 */     if (chr == null || !chr.isAlive() || chr.getMap() == null || chr.hasBlockedInventory()) {
/*  359 */       c.announce(MaplePacketCreator.enableActions());
       return;
     }
/*  362 */     chr.updateTick(slea.readInt());
/*  363 */     short slot = slea.readShort();
/*  364 */     int itemId = slea.readInt();
/*  365 */     Item toUse = chr.getInventory(MapleInventoryType.USE).getItem(slot);
/*  366 */     if (toUse == null || toUse.getQuantity() < 1 || toUse.getItemId() != itemId || itemId / 10000 != 251) {
/*  367 */       c.announce(MaplePacketCreator.enableActions());
       return;
     }
/*  370 */     if (MapleItemInformationProvider.getInstance().getItemEffect(toUse.getItemId()).applyTo(chr)) {
/*  371 */       MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.USE, slot, (short)1, false);
     }
   }




   public static void MakeExtractor(LittleEndianAccessor slea, MapleClient c, MapleCharacter chr) {
/*  379 */     if (chr == null || !chr.isAlive() || chr.getMap() == null || chr.hasBlockedInventory()) {
/*  380 */       c.announce(MaplePacketCreator.enableActions());
       return;
     }
/*  383 */     int itemId = slea.readInt();
/*  384 */     if (itemId > 0) {
/*  385 */       int fee = slea.readInt();
/*  386 */       Item toUse = chr.getInventory(MapleInventoryType.SETUP).findById(itemId);
/*  387 */       if (toUse == null || toUse.getQuantity() < 1 || itemId / 10000 != 304 || fee <= 0 || chr.getExtractor() != null || !chr.getMap().isTown()) {
/*  388 */         c.announce(MaplePacketCreator.enableActions());
         return;
       }
/*  391 */       chr.setExtractor(new MapleExtractor(chr, itemId, fee, chr.getFH()));
/*  392 */       chr.getMap().spawnExtractor(chr.getExtractor());
     } else {
/*  394 */       chr.removeExtractor();
     }
   }




   public static void UseBag(LittleEndianAccessor slea, MapleClient c, MapleCharacter chr) {
/*  402 */     if (chr == null || !chr.isAlive() || chr.getMap() == null || chr.hasBlockedInventory()) {
/*  403 */       c.announce(MaplePacketCreator.enableActions());
       return;
     }
/*  406 */     chr.updateTick(slea.readInt());
/*  407 */     short slot = slea.readShort();
/*  408 */     int itemId = slea.readInt();
/*  409 */     byte type = ItemConstants.getInventoryType(itemId).getType();
/*  410 */     Item toUse = chr.getInventory(ItemConstants.getInventoryType(itemId)).getItem(slot);
/*  411 */     MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
/*  412 */     if (toUse == null || toUse.getQuantity() < 1 || toUse.getItemId() != itemId || (itemId / 10000 != 433 && itemId / 10000 != 308 && itemId / 10000 != 265) || !ii.itemExists(toUse.getItemId())) {
/*  413 */       c.announce(MaplePacketCreator.enableActions());
       return;
     }
/*  416 */     boolean firstTime = !chr.getExtendedSlots(type).contains(Integer.valueOf(itemId));
/*  417 */     if (firstTime) {
/*  418 */       chr.getExtendedSlots(type).add(Integer.valueOf(itemId));
/*  419 */       chr.changedExtended();
/*  420 */       short flag = toUse.getFlag();
/*  421 */       flag = (short)(flag | ItemFlag.封印.getValue());
/*  422 */       flag = (short)(flag | ItemFlag.不可交易.getValue());
/*  423 */       toUse.setFlag(flag);
/*  424 */       chr.forceUpdateItem(toUse);
     }
/*  426 */     else if (!ItemFlag.封印.check(toUse.getFlag())) {
/*  427 */       c.getPlayer().dropMessage(1, ii.getName(itemId) + " 道具只能使用1个.");
/*  428 */       c.announce(MaplePacketCreator.enableActions());

       return;
     }
/*  432 */     c.announce(MaplePacketCreator.openBag(chr.getExtendedSlots(type).indexOf(Integer.valueOf(itemId)), itemId, firstTime));
/*  433 */     c.announce(MaplePacketCreator.enableActions());
   }





   public static void StartHarvest(LittleEndianAccessor slea, MapleClient c, MapleCharacter chr) {
/*  441 */     MapleReactor reactor = chr.getMap().getReactorByOid(slea.readInt());
/*  442 */     if (reactor == null || !reactor.isAlive() || reactor.getReactorId() > 200011) {
/*  443 */       c.announce(MaplePacketCreator.harvestMessage(reactor.getObjectId(), MapleEnumClass.HarvestMsg.HARVEST_UNKNOWN_ERROR));
       return;
     }
/*  446 */     if ((chr.getStat()).harvestingTool <= 0) {
/*  447 */       c.announce(MaplePacketCreator.harvestMessage(reactor.getObjectId(), MapleEnumClass.HarvestMsg.HARVEST_NO_TOOLS));
       return;
     }
/*  450 */     if (chr.getFatigue() >= 200) {
/*  451 */       c.announce(MaplePacketCreator.harvestMessage(reactor.getObjectId(), MapleEnumClass.HarvestMsg.HARVEST_FATIGUE_FULL));
       return;
     }
/*  454 */     if (reactor.getTruePosition().distanceSq(chr.getTruePosition()) > 10000.0D) {
/*  455 */       c.announce(MaplePacketCreator.harvestMessage(reactor.getObjectId(), MapleEnumClass.HarvestMsg.HARVEST_DISTANCE_FAR));

       return;
     }
/*  459 */     Item item = c.getPlayer().getInventory(MapleInventoryType.EQUIP).getItem((short)(chr.getStat()).harvestingTool);
/*  460 */     if (item == null || ((Equip)item).getDurability() == 0) {
/*  461 */       chr.getStat().handleProfessionTool(c.getPlayer());
       return;
     }
/*  464 */     MapleQuestStatus marr = chr.getQuestNAdd(MapleQuest.getInstance(122501));
/*  465 */     if (marr.getCustomData() == null) {
/*  466 */       marr.setCustomData("0");
     }
/*  468 */     long lastTime = Long.parseLong(marr.getCustomData());
/*  469 */     if (lastTime + 5000L > System.currentTimeMillis()) {
/*  470 */       c.announce(MaplePacketCreator.harvestMessage(reactor.getObjectId(), MapleEnumClass.HarvestMsg.HARVEST_UNABLE_COLLECT));
     } else {
/*  472 */       marr.setCustomData(String.valueOf(System.currentTimeMillis()));
/*  473 */       c.announce(MaplePacketCreator.harvestMessage(reactor.getObjectId(), MapleEnumClass.HarvestMsg.HARVEST_ACTION_START));
/*  474 */       chr.getMap().broadcastMessage(chr, MaplePacketCreator.showHarvesting(chr.getId(), item.getItemId()), false);
     }
   }











   public static void StopHarvest(LittleEndianAccessor slea, MapleClient c, MapleCharacter chr) {}










   public static void ProfessionInfo(LittleEndianAccessor slea, MapleClient c, MapleCharacter chr) {
     int rate;
/*  501 */     if (chr == null || chr.getMap() == null) {
/*  502 */       c.announce(MaplePacketCreator.enableActions());
       return;
     }
/*  505 */     String skillid = slea.readMapleAsciiString();
/*  506 */     int level1 = slea.readInt();
/*  507 */     int level2 = slea.readInt();

/*  509 */     if (skillid.startsWith("9200") || skillid.startsWith("9201"))
/*  510 */     { rate = 100; }
/*  511 */     else { if (skillid.startsWith("hyper")) {

/*  513 */         int unk = 0;
/*  514 */         if (level2 == 0 && (level1 == 28 || level1 == 30 || level1 == 32 || level1 == 34 || level1 == 38 || level1 == 40)) {
/*  515 */           unk = 1;
/*  516 */         } else if (level2 == 1 && (level1 == 28 || level1 == 32 || level1 == 36 || level1 == 38 || level1 == 40)) {
/*  517 */           unk = 1;
/*  518 */         } else if (level2 == 2 && (level1 == 30 || level1 == 34 || level1 == 40)) {
/*  519 */           unk = 1;
         }
/*  521 */         c.announce(MaplePacketCreator.updateSpecialStat(skillid, level1, level2, (level1 < 41), unk)); return;
       }
/*  523 */       if (skillid.equalsIgnoreCase("incHyperStat")) {
/*  524 */         rate = 3 + level1 / 10 - 14;
/*  525 */       } else if (skillid.equals("needHyperStatLv")) {
/*  526 */         rate = (level1 < 5) ? (int)Math.pow(2.0D, (level1 - 1)) : ((level1 - 3) * 5);
       } else {
/*  528 */         rate = Math.max(0, 100 - (level1 + 1 - chr.getProfessionLevel(Integer.parseInt(skillid))) * 20);
       }  }
/*  530 */      c.announce(MaplePacketCreator.updateSpecialStat(skillid, level1, level2, true, rate));
   }




   public static void CraftEffect(LittleEndianAccessor slea, MapleClient c, MapleCharacter chr) {
/*  537 */     if (chr.getMapId() != 910001000 && chr.getMap().getExtractorSize() <= 0) {
       return;
     }
/*  540 */     String effect = slea.readMapleAsciiString();
/*  541 */     Integer profession = craftingEffects.get(effect);
/*  542 */     if (profession != null && (chr.getProfessionLevel(profession.intValue()) > 0 || (profession.intValue() == 92040000 && chr.getMap().getExtractorSize() > 0))) {
/*  543 */       int time = slea.readInt();
/*  544 */       if (time > 6000 || time < 3000) {
/*  545 */         time = 4000;
       }
/*  547 */       c.announce(EffectPacket.showOwnCraftingEffect(effect, time, effect.endsWith("Extract") ? 1 : 0));
/*  548 */       chr.getMap().broadcastMessage(chr, EffectPacket.showCraftingEffect(chr.getId(), effect, time, effect.endsWith("Extract") ? 1 : 0), false);
     }
   }




   public static void CraftMake(LittleEndianAccessor slea, MapleClient c, MapleCharacter chr) {
/*  556 */     if (chr.getMapId() != 910001000 && chr.getMap().getExtractorSize() <= 0) {
       return;
     }
/*  559 */     int something = slea.readInt();
/*  560 */     int time = slea.readInt();
/*  561 */     if (time > 6000 || time < 3000) {
/*  562 */       time = 4000;
     }
/*  564 */     chr.getMap().broadcastMessage(MaplePacketCreator.craftMake(chr.getId(), something, time));
   }




   public static void CraftComplete(LittleEndianAccessor slea, MapleClient c, MapleCharacter chr) {
/*  571 */     if (!chr.getCheatTracker().canCraftMake()) {
/*  572 */       chr.sendPolice("系统检测到您的专业技术制作速度异常，系统对您进行掉线处理。");
/*  573 */       c.announce(MaplePacketCreator.enableActions());
/*  574 */       log.info("[作弊] " + chr.getName() + " (等级 " + chr.getLevel() + ") 专业技术制作速度异常。地图ID: " + chr.getMapId());
/*  575 */       WorldBroadcastService.getInstance().broadcastGMMessage(MaplePacketCreator.serverNotice(6, "[GM消息] " + chr.getName() + " ID: " + chr.getId() + " (等级 " + chr.getLevel() + ") 专业技术制作速度异常。地图ID: " + chr.getMapId()));

       return;
     }
/*  579 */     int type = slea.readInt();
/*  580 */     int craftID = slea.readInt();
/*  581 */     if (type == 1) {
/*  582 */       int count = slea.readInt();
/*  583 */       int itemId = 0;
/*  584 */       int itemnum = 0;
/*  585 */       int itempos = 0;
/*  586 */       int toGet = 0;
/*  587 */       int expGain = 0;
/*  588 */       int fatigue = 0;
/*  589 */       short quantity = 1;
/*  590 */       short tloquantity = 0;
/*  591 */       MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
/*  592 */       List<Pair<Integer, Integer>> showItems = new ArrayList();
/*  593 */       List<Pair<Integer, Short>> showItemseff = new ArrayList<>();
/*  594 */       CraftRanking cr = CraftRanking.GOOD;
/*  595 */       for (int i = 0; i < count; i++) {
/*  596 */         craftID = slea.readInt();
/*  597 */         itemId = slea.readInt();
/*  598 */         long invId = slea.readLong();
/*  599 */         itemnum = slea.readInt();
/*  600 */         itempos = slea.readInt();
/*  601 */         int reqLevel = ii.getReqLevel(itemId);
/*  602 */         Item item = chr.getInventory(MapleInventoryType.EQUIP).findByInventoryId(invId, itemId);
/*  603 */         if (item == null || chr.getInventory(MapleInventoryType.ETC).isFull()) {
           return;
         }
/*  606 */         toGet = 4031016;
/*  607 */         quantity = (short)Randomizer.rand(3, (ItemConstants.isWeapon(itemId) || ItemConstants.isOverall(itemId)) ? 11 : 7);
/*  608 */         if (reqLevel <= 60) {

/*  610 */           toGet = 4021013;
/*  611 */         } else if (reqLevel <= 90) {

/*  613 */           toGet = 4021014;
/*  614 */         } else if (reqLevel <= 120) {

/*  616 */           toGet = 4021015;
/*  617 */         } else if (reqLevel >= 130) {
/*  618 */           toGet = 4021016;
         }


/*  622 */         if (Randomizer.nextInt(100) == 60 && toGet != 4031016) {
/*  623 */           toGet++;
/*  624 */           quantity = 1;
         }
/*  626 */         else if (Randomizer.nextInt(100) == 0 && reqLevel > 105) {
/*  627 */           toGet = 4021021;
/*  628 */           quantity = 1;
         }


/*  632 */         MapleInventoryManipulator.addById(c, toGet, quantity, "分解获得 " + itemId + " 时间 " + DateUtil.getCurrentDate());
/*  633 */         MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.EQUIP, item.getPosition(), (short)1, false);
/*  634 */         showItems.add(new Pair(Integer.valueOf(itemId), Integer.valueOf(-1)));
/*  635 */         showItems.add(new Pair(Integer.valueOf(toGet), Integer.valueOf(quantity)));
/*  636 */         showItemseff.add(new Pair(Integer.valueOf(toGet), Short.valueOf(quantity)));
/*  637 */         tloquantity = (short)(tloquantity + quantity);
       }



/*  642 */       if (tloquantity <= 5 && 
/*  643 */         showItemseff.size() == 1)
       {
/*  645 */         cr = CraftRanking.SOSO;
       }

/*  648 */       fatigue = 3 * showItemseff.size();

/*  650 */       MapleQuest.getInstance(2550).forceStart(c.getPlayer(), 9031000, "1");
/*  651 */       chr.setFatigue((byte)(chr.getFatigue() + fatigue));
/*  652 */       chr.getMap().broadcastMessage(MaplePacketCreator.craftExtractorFinished(chr.getId(), craftID, cr.i, expGain, type, showItemseff));
/*  653 */       if (!showItems.isEmpty()) {
            c.announce(EffectPacket.getShowItemGain(showItems));
        }
     } else {
/*  657 */       SkillFactory.CraftingEntry ce = SkillFactory.getCraft(craftID);
/*  658 */       MapleItemInformationProvider ii = MapleItemInformationProvider.getInstance();
/*  659 */       if ((chr.getMapId() != 910001000 && (craftID != 92049000 || chr.getMap().getExtractorSize() <= 0)) || ce == null || chr.getFatigue() >= 200) {
         return;
       }
/*  662 */       int theLevl = chr.getProfessionLevel(craftID / 10000 * 10000);
/*  663 */       if (theLevl <= 0 && craftID != 92049000) {
         return;
       }
/*  666 */       List<Pair<Integer, Integer>> showItems = new ArrayList<>();
/*  667 */       int toGet = 0, expGain = 0, fatigue = 0;
/*  668 */       short quantity = 1;
/*  669 */       CraftRanking cr = CraftRanking.GOOD;
/*  670 */       if (craftID == 92049000) {
/*  671 */         int extractorId = slea.readInt();
/*  672 */         int itemId = slea.readInt();
/*  673 */         long invId = slea.readLong();
/*  674 */         int reqLevel = ii.getReqLevel(itemId);
/*  675 */         Item item = chr.getInventory(MapleInventoryType.EQUIP).findByInventoryId(invId, itemId);
/*  676 */         if (item == null || chr.getInventory(MapleInventoryType.ETC).isFull()) {
           return;
         }
/*  679 */         if (extractorId <= 0 && (theLevl == 0 || theLevl < ((reqLevel > 130) ? 6 : ((reqLevel - 30) / 20))))
           return;
/*  681 */         if (extractorId > 0) {
/*  682 */           MapleCharacter extract = chr.getMap().getCharacterById(extractorId);
/*  683 */           if (extract == null || extract.getExtractor() == null) {
             return;
           }
/*  686 */           MapleExtractor extractor = extract.getExtractor();
/*  687 */           if (extractor.owner != chr.getId()) {
/*  688 */             if (chr.getMeso() < extractor.fee) {
               return;
             }
/*  691 */             MapleStatEffect eff = ii.getItemEffect(extractor.itemId);
/*  692 */             if (eff != null && eff.getUseLevel() < reqLevel) {
               return;
             }
/*  695 */             chr.gainMeso(-extractor.fee, true);
/*  696 */             MapleCharacter owner = chr.getMap().getCharacterById(extractor.owner);
/*  697 */             if (owner != null && owner.getMeso() < (Integer.MAX_VALUE - extractor.fee)) {
/*  698 */               owner.gainMeso(extractor.fee, false);
             }
           }
         }
/*  702 */         toGet = 4031016;
/*  703 */         quantity = (short)Randomizer.rand(3, (ItemConstants.isWeapon(itemId) || ItemConstants.isOverall(itemId)) ? 11 : 7);
/*  704 */         if (reqLevel <= 60) {
/*  705 */           toGet = 4021013;
/*  706 */         } else if (reqLevel <= 90) {
/*  707 */           toGet = 4021014;
/*  708 */         } else if (reqLevel <= 120) {
/*  709 */           toGet = 4021015;
         }
/*  711 */         if (quantity <= 5) {
/*  712 */           cr = CraftRanking.SOSO;
         }
/*  714 */         if (Randomizer.nextInt(5) == 0 && toGet != 4031016) {
/*  715 */           toGet++;
/*  716 */           quantity = 1;
/*  717 */           cr = CraftRanking.COOL;
/*  718 */         } else if (Randomizer.nextInt(100) == 0 && reqLevel > 105) {
/*  719 */           toGet = 4021021;
/*  720 */           quantity = 1;
/*  721 */           cr = CraftRanking.COOL;
         }
/*  723 */         fatigue = 3;
/*  724 */         MapleInventoryManipulator.addById(c, toGet, quantity, "分解获得 " + itemId + " 时间 " + DateUtil.getCurrentDate());
/*  725 */         MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.EQUIP, item.getPosition(), (short)1, false);
/*  726 */         showItems.add(new Pair(Integer.valueOf(itemId), Integer.valueOf(-1)));
/*  727 */         showItems.add(new Pair(Integer.valueOf(toGet), Integer.valueOf(quantity)));
/*  728 */       } else if (craftID == 92049001) {
/*  729 */         int itemId = slea.readInt();
/*  730 */         long invId1 = slea.readLong();
/*  731 */         long invId2 = slea.readLong();
/*  732 */         int reqLevel = ii.getReqLevel(itemId);
/*  733 */         Equip item1 = (Equip)chr.getInventory(MapleInventoryType.EQUIP).findByEquipOnlyId(invId1, itemId);
/*  734 */         Equip item2 = (Equip)chr.getInventory(MapleInventoryType.EQUIP).findByEquipOnlyId(invId2, itemId); short i;
/*  735 */         for (i = 0; i < chr.getInventory(MapleInventoryType.EQUIP).getSlotLimit(); i = (short)(i + 1)) {
/*  736 */           Item item = chr.getInventory(MapleInventoryType.EQUIP).getItem(i);
/*  737 */           if (item != null && item.getItemId() == itemId && item != item1 && item != item2) {
/*  738 */             if (item1 == null) {
/*  739 */               item1 = (Equip)item;
/*  740 */             } else if (item2 == null) {
/*  741 */               item2 = (Equip)item;
               break;
             }
           }
         }
/*  746 */         if (item1 == null || item2 == null) {
           return;
         }
/*  749 */         if (theLevl < ((reqLevel > 130) ? 6 : ((reqLevel - 30) / 20))) {
           return;
         }
/*  752 */         int potentialState = 5, potentialChance = theLevl * 2, toRemove = 1;
/*  753 */         if (reqLevel <= 30) {
/*  754 */           toRemove = 1;
/*  755 */         } else if (reqLevel <= 70) {
/*  756 */           toRemove = 2;
/*  757 */         } else if (reqLevel <= 120) {
/*  758 */           toRemove = 3;
         } else {
/*  760 */           toRemove = 4;
         }
/*  762 */         if (!chr.haveItem(4021017, toRemove)) {
/*  763 */           chr.dropMessage(5, "合成装备需要的炼金术士之石不够，当前需要" + toRemove + "个。");
/*  764 */           c.announce(MaplePacketCreator.enableActions());
           return;
         }
/*  767 */         if (item1.getState(false) > 0 && item2.getState(false) > 0) {
/*  768 */           potentialChance = 100;
/*  769 */         } else if (item1.getState(false) > 0 || item2.getState(false) > 0) {
/*  770 */           potentialChance *= 2;
         }
/*  772 */         if (item1.getState(false) == item2.getState(false) && item1.getState(false) > 5) {
/*  773 */           potentialState = item1.getState(false);
         }

/*  776 */         Equip newEquip = ii.fuse((item1.getLevel() > 0) ? (Equip)ii.getEquipById(itemId) : item1, (item2.getLevel() > 0) ? (Equip)ii.getEquipById(itemId) : item2);
/*  777 */         int newStat = ii.getTotalStat(newEquip);
/*  778 */         if (newStat > ii.getTotalStat(item1) || newStat > ii.getTotalStat(item2)) {
/*  779 */           cr = CraftRanking.COOL;
/*  780 */         } else if (newStat < ii.getTotalStat(item1) || newStat < ii.getTotalStat(item2)) {
/*  781 */           cr = CraftRanking.SOSO;
         }
/*  783 */         if (Randomizer.nextInt(100) < ((newEquip.getUpgradeSlots() > 0 || potentialChance >= 100) ? potentialChance : (potentialChance / 2))) {
/*  784 */           newEquip.resetPotential_Fuse((theLevl > 5), potentialState);
         }
/*  786 */         newEquip.setFlag((short)ItemFlag.CRAFTED.getValue());
/*  787 */         newEquip.setOwner(chr.getName());
/*  788 */         toGet = newEquip.getItemId();
/*  789 */         expGain = 60 - (theLevl - 1) * 4;
/*  790 */         fatigue = 3;
/*  791 */         MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.EQUIP, item1.getPosition(), (short)1, false);
/*  792 */         MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.EQUIP, item2.getPosition(), (short)1, false);
/*  793 */         MapleInventoryManipulator.removeById(c, MapleInventoryType.ETC, 4021017, toRemove, false, false);
/*  794 */         MapleInventoryManipulator.addbyItem(c, (Item)newEquip);
/*  795 */         showItems.add(new Pair(Integer.valueOf(itemId), Integer.valueOf(-1)));
/*  796 */         showItems.add(new Pair(Integer.valueOf(itemId), Integer.valueOf(-1)));
/*  797 */         showItems.add(new Pair(Integer.valueOf(4021017), Integer.valueOf(-toRemove)));
/*  798 */         showItems.add(new Pair(Integer.valueOf(toGet), Integer.valueOf(1)));
       } else {
/*  800 */         if (ce.needOpenItem && chr.getSkillLevel(craftID) <= 0) {
           return;
         }
/*  803 */         for (Map.Entry<Integer, Integer> e : (Iterable<Map.Entry<Integer, Integer>>)ce.reqItems.entrySet()) {
/*  804 */           if (!chr.haveItem(((Integer)e.getKey()).intValue(), ((Integer)e.getValue()).intValue())) {
             return;
           }
         }
/*  808 */         for (Triple<Integer, Integer, Integer> i : (Iterable<Triple<Integer, Integer, Integer>>)ce.targetItems) {
/*  809 */           if (!MapleInventoryManipulator.checkSpace(c, ((Integer)i.left).intValue(), ((Integer)i.mid).intValue(), "")) {
             return;
           }
         }
/*  813 */         for (Map.Entry<Integer, Integer> e : (Iterable<Map.Entry<Integer, Integer>>)ce.reqItems.entrySet()) {
/*  814 */           MapleInventoryManipulator.removeById(c, ItemConstants.getInventoryType(((Integer)e.getKey()).intValue()), ((Integer)e.getKey()).intValue(), ((Integer)e.getValue()).intValue(), false, false);
/*  815 */           showItems.add(new Pair(e.getKey(), Integer.valueOf(-((Integer)e.getValue()).intValue())));
         }
/*  817 */         if (Randomizer.nextInt(100) < 100 - (ce.reqSkillLevel - theLevl) * 20 || craftID / 10000 <= 9201) {
           boolean passed; do {
/*  819 */             passed = false;
/*  820 */             for (Triple<Integer, Integer, Integer> i : (Iterable<Triple<Integer, Integer, Integer>>)ce.targetItems) {
/*  821 */               if (Randomizer.nextInt(100) < ((Integer)i.right).intValue()) {
/*  822 */                 toGet = ((Integer)i.left).intValue();
/*  823 */                 quantity = ((Integer)i.mid).shortValue();
/*  824 */                 Item receive = null;
/*  825 */                 if (ItemConstants.getInventoryType(toGet) == MapleInventoryType.EQUIP) {
/*  826 */                   Equip first = (Equip)ii.getEquipById(toGet);
/*  827 */                   if (Randomizer.nextInt(100) < theLevl * 2) {
/*  828 */                     first = ii.randomizeStats(first);
/*  829 */                     cr = CraftRanking.COOL;
                   }
/*  831 */                   if (Randomizer.nextInt(100) < theLevl * ((first.getUpgradeSlots() > 0) ? 2 : 1)) {
/*  832 */                     first.renewPotential(false);
/*  833 */                     cr = CraftRanking.COOL;
                   }
/*  835 */                   Equip equip1 = first;


/*  838 */                   EnhanceResultType enhanceResultType = null;
/*  839 */                   if (theLevl == 11) {
/*  840 */                     enhanceResultType = EnhanceResultType.ARTISAN;
/*  841 */                   } else if (theLevl == 12) {
/*  842 */                     enhanceResultType = EnhanceResultType.FAMOUS_ARTISAN;
                   }
/*  844 */                   if (enhanceResultType != null) {
/*  845 */                     equip1.setEnhanctBuff(enhanceResultType.getValue());
                   }
/*  847 */                   equip1.setFlag((short)ItemFlag.CRAFTED.getValue());
                 } else {
/*  849 */                   receive = new Item(toGet, (short)0, quantity, (short)ItemFlag.可以交换1次.getValue());
                 }
/*  851 */                 if (ce.period > 0) {
/*  852 */                   long period = ce.period;
/*  853 */                   receive.setExpiration(System.currentTimeMillis() + period * 60L * 1000L);
                 }
/*  855 */                 receive.setOwner(chr.getName());
/*  856 */                 receive.setGMLog("制作装备 " + craftID + " 在 " + DateUtil.getCurrentDate());
/*  857 */                 MapleInventoryManipulator.addFromDrop(c, receive, false, false);
/*  858 */                 showItems.add(new Pair(Integer.valueOf(receive.getItemId()), Integer.valueOf(receive.getQuantity())));
/*  859 */                 if (ce.needOpenItem) {
/*  860 */                   byte mLevel = chr.getMasterLevel(craftID);
/*  861 */                   if (mLevel == 1) {
/*  862 */                     chr.changeSingleSkillLevel((Skill)ce, 0, (byte)0);
/*  863 */                   } else if (mLevel > 1) {
/*  864 */                     chr.changeSingleSkillLevel((Skill)ce, 2147483647, (byte)(chr.getMasterLevel(craftID) - 1));
                   }
                 }
/*  867 */                 fatigue = ce.incFatigability;
/*  868 */                 expGain = (ce.incSkillProficiency == 0) ? (fatigue * 20 - (ce.reqSkillLevel - theLevl) * 4) : ce.incSkillProficiency;
/*  869 */                 chr.getTrait(MapleTraitType.craft).addExp(cr.craft, chr);
/*  870 */                 passed = true;
                 break;
               }
             }
/*  874 */           } while (!passed);

         }
         else {

/*  879 */           quantity = 0;
/*  880 */           cr = CraftRanking.FAIL;
         }
       }
/*  883 */       if (expGain > 0 && theLevl < 10) {
/*  884 */         expGain *= chr.isAdmin() ? 20 : ServerConfig.CHANNEL_RATE_TRAIT;
/*  885 */         if (Randomizer.nextInt(100) < chr.getTrait(MapleTraitType.craft).getLevel() / 5) {
/*  886 */           expGain *= 2;
         }
/*  888 */         String s = "炼金术";
/*  889 */         switch (craftID / 10000) {
           case 9200:
/*  891 */             s = "采药";
             break;
           case 9201:
/*  894 */             s = "采矿";
             break;
           case 9202:
/*  897 */             s = "装备制作";
             break;
           case 9203:
/*  900 */             s = "饰品制作";
             break;
         }
/*  903 */         chr.dropMessage(-5, s + "的熟练度提高了。(+" + expGain + ")");
/*  904 */         if (chr.addProfessionExp(craftID / 10000 * 10000, expGain)) {
/*  905 */           chr.dropMessage(-5, s + "的等级提升了。");
         }
       } else {
/*  908 */         expGain = 0;
       }
/*  910 */       MapleQuest.getInstance(2550).forceStart(c.getPlayer(), 9031000, "1");
/*  911 */       chr.setFatigue((byte)(chr.getFatigue() + fatigue));
/*  912 */       chr.getMap().broadcastMessage(MaplePacketCreator.craftFinished(chr.getId(), craftID, cr.i, toGet, quantity, expGain));
/*  913 */       if (!showItems.isEmpty()) {
/*  914 */         c.announce(EffectPacket.getShowItemGain(showItems));
       }
     }
   }






   public static void UsePot(LittleEndianAccessor slea, MapleClient c) {
/*  925 */     int itemid = slea.readInt();
/*  926 */     Item slot = c.getPlayer().getInventory(MapleInventoryType.USE).getItem(slea.readShort());
/*  927 */     if (slot == null || slot.getQuantity() <= 0 || slot.getItemId() != itemid || itemid / 10000 != 244 || MapleItemInformationProvider.getInstance().getPot(itemid) == null) {
/*  928 */       c.announce(MaplePacketCreator.enableActions());
       return;
     }
/*  931 */     c.announce(MaplePacketCreator.enableActions());
/*  932 */     for (int i = 0; i < (c.getPlayer().getImps()).length; i++) {
/*  933 */       if (c.getPlayer().getImps()[i] == null) {
/*  934 */         c.getPlayer().getImps()[i] = new MapleImp(itemid);
/*  935 */         c.announce(MaplePacketCreator.updateImp(c.getPlayer().getImps()[i], ImpFlag.SUMMONED.getValue(), i, false));
/*  936 */         MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.USE, slot.getPosition(), (short)1, false, false);
         return;
       }
     }
   }




   public static void ClearPot(LittleEndianAccessor slea, MapleClient c) {
/*  946 */     int index = slea.readInt() - 1;
/*  947 */     if (index < 0 || index >= (c.getPlayer().getImps()).length || c.getPlayer().getImps()[index] == null) {
/*  948 */       c.announce(MaplePacketCreator.enableActions());
       return;
     }
/*  951 */     c.announce(MaplePacketCreator.updateImp(c.getPlayer().getImps()[index], ImpFlag.REMOVED.getValue(), index, false));
/*  952 */     c.getPlayer().getImps()[index] = null;
   }




   public static void FeedPot(LittleEndianAccessor slea, MapleClient c) {
/*  959 */     int itemid = slea.readInt();
/*  960 */     Item slot = c.getPlayer().getInventory(ItemConstants.getInventoryType(itemid)).getItem((short)slea.readInt());
/*  961 */     if (slot == null || slot.getQuantity() <= 0 || slot.getItemId() != itemid) {
/*  962 */       c.announce(MaplePacketCreator.enableActions());
       return;
     }
/*  965 */     int level = (ItemConstants.getInventoryType(itemid) == MapleInventoryType.ETC) ? MapleItemInformationProvider.getInstance().getItemMakeLevel(itemid) : MapleItemInformationProvider.getInstance().getReqLevel(itemid);
/*  966 */     if (level <= 0 || level < Math.min(120, c.getPlayer().getLevel()) - 50 || (ItemConstants.getInventoryType(itemid) != MapleInventoryType.ETC && ItemConstants.getInventoryType(itemid) != MapleInventoryType.EQUIP)) {
/*  967 */       c.getPlayer().dropMessage(1, "喂养道具宝宝出错。");
/*  968 */       c.announce(MaplePacketCreator.enableActions());
       return;
     }
/*  971 */     int index = slea.readInt() - 1;
/*  972 */     if (c.getPlayer().isAdmin()) {
/*  973 */       c.getPlayer().dropMessage(5, "喂养道具宝宝 index: " + index);
     }
/*  975 */     if (index < 0 || index >= (c.getPlayer().getImps()).length || c.getPlayer().getImps()[index] == null || c.getPlayer().getImps()[index].getLevel() >= ((Integer)(MapleItemInformationProvider.getInstance().getPot(c.getPlayer().getImps()[index].getItemId())).right).intValue() - 1 || c.getPlayer().getImps()[index].getState() != 1) {
/*  976 */       c.announce(MaplePacketCreator.enableActions());
       return;
     }
/*  979 */     int mask = ImpFlag.FULLNESS.getValue();
/*  980 */     mask |= ImpFlag.FULLNESS_2.getValue();
/*  981 */     mask |= ImpFlag.UPDATE_TIME.getValue();
/*  982 */     mask |= ImpFlag.AWAKE_TIME.getValue();

/*  984 */     c.getPlayer().getImps()[index].setFullness(c.getPlayer().getImps()[index].getFullness() + 100 * ((ItemConstants.getInventoryType(itemid) == MapleInventoryType.EQUIP) ? 2 : 1));
/*  985 */     if (Randomizer.nextBoolean()) {
/*  986 */       mask |= ImpFlag.CLOSENESS.getValue();
/*  987 */       c.getPlayer().getImps()[index].setCloseness(c.getPlayer().getImps()[index].getCloseness() + 1 + Randomizer.nextInt(5 * ((ItemConstants.getInventoryType(itemid) == MapleInventoryType.EQUIP) ? 2 : 1)));
/*  988 */     } else if (Randomizer.nextInt(5) == 0) {
/*  989 */       c.getPlayer().getImps()[index].setState(4);
/*  990 */       mask |= ImpFlag.STATE.getValue();
     }
/*  992 */     if (c.getPlayer().getImps()[index].getFullness() >= 1000) {
/*  993 */       c.getPlayer().getImps()[index].setState(1);
/*  994 */       c.getPlayer().getImps()[index].setFullness(0);
/*  995 */       c.getPlayer().getImps()[index].setLevel(c.getPlayer().getImps()[index].getLevel() + 1);
/*  996 */       mask |= ImpFlag.SUMMONED.getValue();
/*  997 */       if (c.getPlayer().getImps()[index].getLevel() >= ((Integer)(MapleItemInformationProvider.getInstance().getPot(c.getPlayer().getImps()[index].getItemId())).right).intValue() - 1) {
/*  998 */         c.getPlayer().getImps()[index].setState(5);
       }
     }
/* 1001 */     MapleInventoryManipulator.removeFromSlot(c, ItemConstants.getInventoryType(itemid), slot.getPosition(), (short)1, false, false);
/* 1002 */     c.announce(MaplePacketCreator.updateImp(c.getPlayer().getImps()[index], mask, index, false));
   }





   public static void CurePot(LittleEndianAccessor slea, MapleClient c) {
/* 1010 */     int itemid = slea.readInt();
/* 1011 */     Item slot = c.getPlayer().getInventory(MapleInventoryType.ETC).getItem((short)slea.readInt());
/* 1012 */     if (slot == null || slot.getQuantity() <= 0 || slot.getItemId() != itemid || itemid / 10000 != 434) {
/* 1013 */       c.announce(MaplePacketCreator.enableActions());
       return;
     }
/* 1016 */     int index = slea.readInt() - 1;
/* 1017 */     if (c.getPlayer().isAdmin()) {
/* 1018 */       c.getPlayer().dropMessage(5, "治愈道具宝宝 index: " + index);
     }
/* 1020 */     if (index < 0 || index >= (c.getPlayer().getImps()).length || c.getPlayer().getImps()[index] == null || c.getPlayer().getImps()[index].getState() != 4) {
/* 1021 */       c.announce(MaplePacketCreator.enableActions());
       return;
     }
/* 1024 */     c.getPlayer().getImps()[index].setState(1);
/* 1025 */     c.announce(MaplePacketCreator.updateImp(c.getPlayer().getImps()[index], ImpFlag.STATE.getValue(), index, false));
/* 1026 */     MapleInventoryManipulator.removeFromSlot(c, MapleInventoryType.ETC, slot.getPosition(), (short)1, false, false);
   }




   public static void RewardPot(LittleEndianAccessor slea, MapleClient c) {
/* 1033 */     int index = slea.readInt() - 1;
/* 1034 */     if (c.getPlayer().isAdmin()) {
/* 1035 */       c.getPlayer().dropMessage(5, "道具宝宝奖励 index: " + index);
     }
/* 1037 */     if (index < 0 || index >= (c.getPlayer().getImps()).length || c.getPlayer().getImps()[index] == null || c.getPlayer().getImps()[index].getLevel() < ((Integer)(MapleItemInformationProvider.getInstance().getPot(c.getPlayer().getImps()[index].getItemId())).right).intValue() - 1) {
/* 1038 */       c.announce(MaplePacketCreator.enableActions());
       return;
     }
/* 1041 */     int itemid = ItemConstants.getRewardPot(c.getPlayer().getImps()[index].getItemId(), c.getPlayer().getImps()[index].getCloseness());
/* 1042 */     if (itemid <= 0 || !MapleInventoryManipulator.checkSpace(c, itemid, 1, "")) {
/* 1043 */       c.getPlayer().dropMessage(1, "您的背包空间不足。");
/* 1044 */       c.announce(MaplePacketCreator.enableActions());
       return;
     }
/* 1047 */     MapleInventoryManipulator.addById(c, itemid, (short)1, "道具宝宝 " + c.getPlayer().getImps()[index].getItemId() + " 在 " + DateUtil.getCurrentDate());
/* 1048 */     c.announce(MaplePacketCreator.updateImp(c.getPlayer().getImps()[index], ImpFlag.REMOVED.getValue(), index, false));
/* 1049 */     c.getPlayer().getImps()[index] = null;
   }

   public enum CraftRanking
   {
/* 1054 */     SOSO(24, 30),
/* 1055 */     GOOD(25, 40),
/* 1056 */     COOL(26, 50),




/* 1061 */     FAIL(28, 20);
     public final int i;
     public final int craft;

     CraftRanking(int i, int craft) {
/* 1066 */       this.i = i;
/* 1067 */       this.craft = craft;
     }
   }
 }


/* Location:              C:\PGX\Server.jar!\handling\channel\handler\ItemMakerHandler.class
 * Java compiler version: 8 (52.0)
 * JD-Core Version:       1.1.3
 */